package calcul;
import sun.audio.*;
import java.io.*;
import java.util.Random;

public class Audio {
		
	private AudioStream as;
	
	public void lectureAudio(){
		 try {
			 InputStream in = new FileInputStream("sounds/sonrambo.wav");
			 switch(nombreAleatoire()){
			 case 0:
				 in = new FileInputStream("sounds/sonrambo.wav");
				 break;
			 case 1:
				 in = new FileInputStream("sounds/sonelectra.wav");
				 break;
			 case 2:
				 in = new FileInputStream("sounds/sonmelodine.wav");
				 break;
			 case 3:
				 in = new FileInputStream("sounds/sonrobot.wav");
				 break;
			 case 4:
				 in = new FileInputStream("sounds/sonsorciere.wav");
				 break;
			 }
			 
			 as = new AudioStream(in);
			 AudioPlayer.player.start(as);
			 } catch (Exception exc){}
	}
	
	public int nombreAleatoire(){
		Random random = new Random(); 
		int nombreAleatoire = random.nextInt(5);
		return nombreAleatoire;
	}
	
	public void arretLecture(){
		AudioPlayer.player.stop(as);
	}
	
}

